function loader(source){
  let pos = 0;
  let current;
  const reg = /url\((.+?)\)/g;
  let arr = ['let list = []']
  while(current = reg.exec(source)){
    // console.log('====',current);
    const [match,content] = current
    let last = reg.lastIndex - match.length
    arr.push(`list.push(${JSON.stringify(source.slice(pos,last))})`)
    arr.push(`list.push('url('+require(${content})+')')`)
    pos = reg.lastIndex
  }
  arr.push(`list.push(${JSON.stringify(source.slice(pos))})`)
  arr.push(`module.exports = list.join(' ')`)
  return arr.join('\r\n')
}

module.exports = loader